package com.aynu.gulimall.order.service.impl;

import com.mysql.cj.util.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.aynu.common.utils.PageUtils;
import com.aynu.common.utils.Query;

import com.aynu.gulimall.order.dao.OrderItemDao;
import com.aynu.gulimall.order.entity.OrderItemEntity;
import com.aynu.gulimall.order.service.OrderItemService;


@Service("orderItemService")
public class OrderItemServiceImpl extends ServiceImpl<OrderItemDao, OrderItemEntity> implements OrderItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String key = (String) params.get("key");
        QueryWrapper<OrderItemEntity> wrapper = new QueryWrapper<>();

        if (!StringUtils.isEmptyOrWhitespaceOnly(key))
        {
            wrapper.eq("order_sn",key).or().like("spu_name",key);
        }
        IPage<OrderItemEntity> page = this.page(
                new Query<OrderItemEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}